package com.sina.weibo;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.net.Uri;
import android.text.TextUtils;

public class NetworkUtil
{
  static final Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
  static APNWrapper wrapper;

  public static APNWrapper getAPN(Context paramContext)
  {
    ContentResolver localContentResolver = paramContext.getContentResolver();
    Uri localUri = PREFERRED_APN_URI;
    String[] arrayOfString1 = new String[4];
    arrayOfString1[0] = "name";
    arrayOfString1[1] = "apn";
    arrayOfString1[2] = "proxy";
    arrayOfString1[3] = "port";
    String[] arrayOfString2 = null;
    String str1 = null;
    Cursor localCursor = localContentResolver.query(localUri, arrayOfString1, null, arrayOfString2, str1);
    boolean bool = localCursor.moveToFirst();
    if (wrapper == null)
      wrapper = new APNWrapper();
    APNWrapper localAPNWrapper2;
    if (localCursor.isAfterLast())
    {
      wrapper.name = "N/A";
      wrapper.apn = "N/A";
      APNWrapper localAPNWrapper1 = wrapper;
      String str2 = Proxy.getDefaultHost();
      localAPNWrapper1.proxy = str2;
      localAPNWrapper2 = wrapper;
      if (!TextUtils.isEmpty(wrapper.proxy))
        break label295;
      String str3 = "";
      label142: localAPNWrapper2.proxy = str3;
      APNWrapper localAPNWrapper3 = wrapper;
      int k = Proxy.getDefaultPort();
      localAPNWrapper3.port = k;
      localAPNWrapper2 = wrapper;
      if (wrapper.port <= 0)
        break label306;
    }
    label226: int j;
    label279: label295: label306: for (int i = wrapper.port; ; j = 80)
    {
      localAPNWrapper2.port = i;
      localCursor.close();
      return wrapper;
      localAPNWrapper2 = wrapper;
      if (localCursor.getString(0) == null)
      {
        str4 = "";
        localAPNWrapper2.name = str4;
        localAPNWrapper2 = wrapper;
        if (localCursor.getString(1) != null)
          break label279;
      }
      for (String str4 = ""; ; str4 = localCursor.getString(1).trim())
      {
        localAPNWrapper2.apn = str4;
        break;
        str4 = localCursor.getString(0).trim();
        break label226;
      }
      str4 = wrapper.proxy;
      break label142;
    }
  }

  public static NetworkState getNetworkState(Context paramContext)
  {
    NetworkInfo localNetworkInfo = ((ConnectivityManager)paramContext.getSystemService("connectivity")).getActiveNetworkInfo();
    NetworkState localNetworkState;
    if ((localNetworkInfo == null) || (!localNetworkInfo.isAvailable()))
      localNetworkState = NetworkState.NOTHING;
    while (true)
    {
      return localNetworkState;
      if (localNetworkInfo.getType() == 0)
      {
        localNetworkState = NetworkState.MOBILE;
        continue;
      }
      localNetworkState = NetworkState.WIFI;
    }
  }

  public class APNWrapper
  {
    String apn;
    String name;
    int port;
    String proxy;

    public String getApn()
    {
      return this.apn;
    }

    public String getName()
    {
      return this.name;
    }

    public int getPort()
    {
      return this.port;
    }

    public String getProxy()
    {
      return this.proxy;
    }
  }

  public enum NetworkState
  {
    static
    {
      MOBILE = new NetworkState("MOBILE", 1);
      WIFI = new NetworkState("WIFI", 2);
      NetworkState[] arrayOfNetworkState = new NetworkState[3];
      NetworkState localNetworkState1 = NOTHING;
      arrayOfNetworkState[0] = localNetworkState1;
      NetworkState localNetworkState2 = MOBILE;
      arrayOfNetworkState[1] = localNetworkState2;
      NetworkState localNetworkState3 = WIFI;
      arrayOfNetworkState[2] = localNetworkState3;
      ENUM$VALUES = arrayOfNetworkState;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.NetworkUtil
 * JD-Core Version:    0.6.0
 */